#pragma once

//Natural Headers
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <assert.h>
#pragma comment (lib,"Winmm.lib")
#include <iostream>
#include <time.h>
using namespace std;

//Created Headers
#include "resource.h"
#include "Pen.h"
#include "Video Screen.h"
#include "Object Files.h"
#include "Input.h"
#include "Audio.h"
#include "World.h"
#include "Globals.h"

//Holds every drawable
extern DrawList* Objects3D;
extern DrawList* ObjectsSprite;

//Allows usage of these variables
// Needed becauses they are intialized and modified at run time
extern int WORLD_HEIGHT;
extern int WORLD_WIDTH;

//All player interactable objects in game
static DrawList* Objects3D = new DrawList();
//All menu objects
static DrawList* ObjectsSprite = new DrawList();
//All objects that need to be safetly cleaned up
static DrawList* Remove3D = new DrawList();

//This controls the game and all of its modules
//It also manages all of the objects in the world, along with all the walls
// that make up the world
//
//A basic state machine method is used to control what the class should do.
// Init-Update-Quit
//
//The game holds a pointer to the Menu and Player since they remain constant through every level
class GAME
{
private:
	GAME()
		: GameState(GAME_STATE_SIZE)
		, ElapsedTime(0)
	{}
	HWND					m_hWnd;
	//Allows for easier access
	Menu*					m_Sidebar;
	Character*				m_Player;

	//The state of the Commander
	eGameStates				GameState;

	//Used to calculate new speed
	double					ElapsedTime;
	bool					SetTimeElapsed;
public:
	inline static GAME* Engine()
	{static GAME Commander;return &Commander;}

	//Initializes everything in the game once
	bool Initialize(HWND hWnd,HINSTANCE hInst,HINSTANCE hPrevInst,int nCmdShow,LPSTR lpCmdLine);
	//Calls all the shutdowns for all the singletons
	void CleanUp();
	//Deletes and recreates the World singleton, all enemies and items
	void RESETWORLD();

	void DRAW();
	void INPUT();

	//Checks if it has been a second\
	//Updates in clocke
	bool TICK(int Type);
	double CLOCK();

	void UPDATE();
	//Checks gamestate and does whatever needs done
	void WORK();

	//Only access when in reference to the character
	bool LOST(int L);
	bool WON(int W);

	Character*	Player(){return m_Player;}
	Menu*		Sidebar(){return m_Sidebar;}
};